package com.h3bpm.web.instance.costReportNo.dao.impl;

import com.h3bpm.web.instance.costReportNo.dao.CostReportNoDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：cjj
 * @date ：Created in 2020/11/16 15:28
 */
@Repository
public class CostReportNoDaoImpl implements CostReportNoDao {

    @Qualifier("secondaryJdbcTemplate")
    @Autowired
    private JdbcTemplate secondaryDataSource;

    @Override
    public String getMaxCostReportNo() {
        String sql="select max(造价报告号) from [OA_yw_实施台账_造价报告管理]";
        Object obj = secondaryDataSource.queryForObject(sql, Object.class);
        return (String)obj;
    }

    @Override
    public List<Map<String, Object>> getHistoryCostNo(String projectCode, String businessStatus) {
        String sql = "select [报告名称] as costName,[造价报告号] as costNo from OA_yw_实施台账_造价报告管理 where [项目代码]=‘"+projectCode+"'";
        if(StringUtils.isNotBlank(businessStatus)){
            sql += sql+" and [EC业务状态] =‘"+businessStatus+"'";
        }
        return secondaryDataSource.queryForList(sql);
    }
}
